package com.liruo.srpingframework.dataaccess.transaction.customize;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource;

public class ProxyAnnotationTransactionAttributeSourceBeanProcessor implements
    InstantiationAwareBeanPostProcessor,
    PriorityOrdered {
  @Override
  public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName)
      throws BeansException {
    if (!beanClass.isAssignableFrom(AnnotationTransactionAttributeSource.class)) {
      return null;
    }
    return new AnnotationTransactionAttributeSource(false);
  }
  @Override
  public int getOrder() {
    return Ordered.HIGHEST_PRECEDENCE;
  }
}